package com.sky.service.impl;

import com.sky.result.Result;
import com.sky.service.ShopStatusService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class ShopStatusServiceImpl implements ShopStatusService {
    private final static String key = "SHOP_STATUS";
    @Autowired
    private StringRedisTemplate stringRedisTemplate;
    /**
     * 更改商店启用和禁用
     *
     * @param status
     * @return
     */
    @Override
    @Transactional
    public Result updateStatus(Integer status) {
        stringRedisTemplate.opsForValue().set(key,status.toString());
        return Result.success();
    }

    /**
     * 得到管理端的状态
     *
     * @return
     */
    @Override
    public Result getStatus() {
        String key1 = stringRedisTemplate.opsForValue().get(key);
        return Result.success(Integer.parseInt(key1));
    }
}
